import { Sequelize, DataTypes } from 'sequelize';
import initializeDataBase from '@src/db/db';

const GroupModel = async () => {
    const sequelize: Sequelize = await initializeDataBase();
    sequelize.define('group',{
        id:{
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true,
        },
        name: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        description: {
            type: DataTypes.STRING,
            allowNull: false,
        }
    })

    await sequelize.sync({alter: true}); // Sincroniza o modelo com o banco de dados
    return sequelize.models.group;
}

export default GroupModel